from threading import Thread
from time import sleep


class MyThread(Thread):
    def __init__(self,name):
        Thread.__init__(self)
        self.name = name

    def run(self):
        print(f'{self.name}开始')
        for i in range(5):
            print(f'{self.name}--{i}')
            sleep(1)
        print(f'{self.name}结束')

if __name__ == '__main__':
    print('主线程开始')
    # 创建线程
    t1 = MyThread('线程1')
    t2 = MyThread('线程2')
    # 启动线程
    t1.start()
    t2.start()

    print('主线程结束')